package git

import (
	"context"
	"gitee.com/kmyss/gf-ex/yscmd"
	"gitee.com/kmyss/ys-cli/internal/cmd/git/bundle/clone"
	"gitee.com/kmyss/ys-cli/internal/cmd/git/bundle/create"
	"gitee.com/kmyss/ys-cli/internal/cmd/git/bundle/merge"
	"gitee.com/kmyss/ys-cli/internal/cmd/git/bundle/pull"
	"gitee.com/kmyss/ys-cli/internal/cmd/git/commitmsg"
)

type Builder struct {
	yscmd.CommandBuilderCore
}

func (b *Builder) Init(ctx context.Context) {
	b.CommandBuilderCore.Init(ctx)
	b.C.Use = "git"
	b.C.Short = "git 项目相关辅助功能函数"
	b.C.Long = `
    - 提供 git 钩子函数文件的辅助, 支持的钩子有: commit-msg pre-commit pre-push
    - 提供离线 git 的使用支持。
`
	b.addCommand()
	b.addFlag()
}

func (b *Builder) addCommand() {
	b.SetChildCommands(
		&create.Builder{},
		&clone.Builder{},
		&pull.Builder{},
		&merge.Builder{},
		&commitmsg.Builder{},
		&yscmd.CmdHelpBuilder{},
	)
}

func (b *Builder) addFlag() {
	b.SetFlag(&yscmd.FlagDebugBuilder{})
}

func Git(ctx context.Context) *yscmd.Command {
	c := &Builder{}
	c.Init(ctx)
	return c.Command()
}
